home *** CD-ROM | disk | FTP | other *** search
-
- // Copyright (c) 1998, 1999 Macromedia. All rights reserved.
-
- fw.checkFwJsVersion(0);
-
- function enquote(str)
- {
- if (str == null)
- return "null";
-
- return "\"" + str.toString() + "\"";
- }
-
- function determineQuadrant(pos)
- {
- var screen = fw.screenRect;
- var ldelta = pos.left - screen.left;
- var rdelta = screen.right - pos.right;
- var tdelta = pos.top - screen.top;
- var bdelta = screen.bottom - pos.bottom;
- if (ldelta < rdelta) {
- // left-hand side
- if (tdelta < bdelta) {
- // top-left quadrant
- return 0;
- } else {
- // bottom-left quadrant
- return 1;
- }
- } else {
- // right-hand side
- if (tdelta < bdelta) {
- // top-right quadrant
- return 2;
- } else {
- // bottom-right quadrant
- return 3;
- }
- }
- }
-
- function getAnchorPointForQuadrant(quadrant)
- {
- var anchor = null;
- var screen = fw.screenRect;
- switch (quadrant) {
- case 0: anchor = { x: screen.left, y: screen.top }; break;
- case 1: anchor = { x: screen.left, y: screen.bottom }; break;
- case 2: anchor = { x: screen.right, y: screen.top }; break;
- case 3: anchor = { x: screen.right, y: screen.bottom }; break;
- }
- return anchor;
- }
-
- function toRelativePos(quadrant, pos)
- {
- var anchor = getAnchorPointForQuadrant(quadrant);
- var npos = { left: pos.left - anchor.x, right: pos.right - anchor.x, top: pos.top - anchor.y, bottom: pos.bottom - anchor.y };
- return npos;
- }
-
- function fromRelativePos(quadrant, pos)
- {
- var anchor = getAnchorPointForQuadrant(quadrant);
- var npos = { left: pos.left + anchor.x, right: pos.right + anchor.x, top: pos.top + anchor.y, bottom: pos.bottom + anchor.y };
- return npos;
- }
-
- function setRelativeFloaterPosition(tabname, quadrant, pos)
- {
- var npos = fromRelativePos(quadrant, pos);
- fw.setFloaterPosition(tabname, npos);
- }
-
- var jscode = "";
-
- jscode += getAnchorPointForQuadrant.toSource();
- jscode += fromRelativePos.toSource();
- jscode += setRelativeFloaterPosition.toSource();
-
- var floaters = fw.getFloaterGroupings();
- jscode += "//" + floaters.toSource() + "\n";
- for (i in floaters) {
- var tabsInCurFloater = floaters[i];
-
- // first, get the groupings right
- var anyVisible = false;
- var mainTabName = null;
- var visibleTabName = null;
- for (j in tabsInCurFloater) {
- var tabName = tabsInCurFloater[j];
-
- if (fw.getFloaterVisibility(tabName))
- visibleTabName = tabName;
-
- jscode += "fw.setFloaterGrouping(" + enquote(tabName) + ", " + enquote(mainTabName) + ");";
- jscode += "\n";
-
- if (mainTabName == null)
- mainTabName = tabName;
- }
-
- if (visibleTabName != null) {
- jscode += "fw.setFloaterVisibility(" + enquote(visibleTabName) + ", true);";
- jscode += "\n";
- } else {
- jscode += "fw.setFloaterVisibility(" + enquote(mainTabName) + ", false);";
- jscode += "\n";
- }
-
- var abspos = fw.getFloaterPosition(mainTabName);
- var quadrant = determineQuadrant(abspos);
- var relpos = toRelativePos(quadrant, abspos);
- jscode += "setRelativeFloaterPosition(" + enquote(mainTabName) + ", " + quadrant + ", " + relpos.toSource() + ");";
- jscode += "\n";
-
- jscode += "\n";
- }
-
- var filename = prompt("Name your panel layout. Saved panel layouts display in the Commands menu.");
- if (filename != null) {
- var destDir = App.appJsCommandsDir + "/Panel Layout Sets";
- if (!Files.exists(destDir))
- Files.createDirectory(destDir);
- fw.saveJsCommand(jscode, destDir + "/" + filename);
- }
-